/******************************************************************************
 * The contents of this file are subject to the   JDI License  Version 1.0
 * ("License"); You may not use this file except in compliance with the License
 * Software distributed under the License is distributed on an  "AS IS"  basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
 * the specific language governing rights and limitations under the License.
 * The Initial Developer of the Original Code is 陈慧然. Portions created by 
 * 陈慧然 are Copyright 陈慧然.
 * All Rights Reserved.
 *
 *              Contact john_holen@163.com for licensing alternatives.
 *
 *****************************************************************************/


package org.peony.client.web.tools;

import java.text.Collator;

import org.peony.models.MCol;

/**
 *  
 *
 *  @author     陈慧然
 *  @version    Id: ColsComparator.java, v 0.000 2008-4-25 下午09:58:18 陈慧然 Exp
 */
public class ColsComparator implements java.util.Comparator<MCol> {
	public int compare(MCol element1, MCol element2){
		if(element1.getId().equals(element2.getId()))
			throw new DataTableException("CANNOT PARSE DATA TO A TABLE, BECAUSE THERE ARE SAME IDS IN THE COLUMNS.");
		int key1 = element1.getSeq();
		int key2 = element2.getSeq();
		if(key1 == key2)
			throw new DataTableException("CANNOT PARSE DATA TO A TABLE, BECAUSE THERE ARE SAME COLUMNS HAS NO SEQNUM.");
		return key1<key2?-1:1;
	}
}
